using System;
using System.Linq;
using Technullogy.Web.UI.TwcWeather;

namespace Technullogy.Web.UI.Weather.TechnullogyWeather
{
    // Methods for returning XML inner text and node attributes
    // Weather forecast class
    internal class WeatherForecast
    {
        public String High { get; set; }
        public String Low { get; set; }
        public String Sunrise { get; set; }
        public String Sunset { get; set; }
        public DayPartDetails DayDetails { get; set; }
        public DayPartDetails NightDetails { get; set; }
        public String ForecastDay { get; set; }
        public String ForecastShortDay { get; set; }
        public String ForecastDate { get; set; }

        public WeatherForecast(weather twcWeather, String day)
        {
            weatherDayfDay dayForecast = twcWeather.dayf.day.Where(d => d.d == day).FirstOrDefault();
            if (dayForecast == null)
                return;

            ForecastDate = dayForecast.dt;
            ForecastDay = dayForecast.t;
            ForecastShortDay =  (!String.IsNullOrEmpty(ForecastDay)) ? ForecastDay.Substring(0,3) : String.Empty;
            High = dayForecast.hi;
            Low = dayForecast.low;
            Sunrise = dayForecast.sunr;
            Sunset = dayForecast.suns;

            DayDetails = new DayPartDetails(twcWeather, day, "d");
            NightDetails = new DayPartDetails(twcWeather, day, "n");
        }
    }
}
